package com.base.controller;

import com.base.comm.CommContent;
import com.base.po.voip.FilmAge;
import com.base.service.FilmAgeService;
import com.base.service.LogsService;
import com.base.utils.IP;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 修改电影年份服务端
 *
 * @author f
 */
@Controller
@RequestMapping("/admin")
public class update_FilmAge {

    @Autowired
    private LogsService logsService; // log日志
    @Autowired
    private FilmAgeService filmageService; // 电影信息

    // 修改电影信息
    @RequestMapping(value = "/toUpdateFilmAge", method = RequestMethod.POST)
    public @ResponseBody
    int toUpdateFilmAge(HttpServletRequest request, FilmAge filmAge) throws Exception {
        if (request.getSession().getAttribute("adminUserId") == null) return -1; // 未登录
        logsService.insert(CommContent.TYPE_UPDATE, CommContent.LOGS_UPDATE + "改动电影年份信息",
                (String) request.getSession().getAttribute("userNick"), true, IP.getIpAddr(request)); // 记录修改日志
        return filmageService.updateByPrimaryKeySelective(filmAge); // 修改
    }
}
